CMS Ubuntu Linux

How to Setup Joomla on Ubuntu with Nginx & Cloudflare

Richard
Written by
Richard
Apr 24, 2019 Updated Apr 18, 2026 6 min read

This guide explains how to set up the Joomla website builder on an Ubuntu Linux server. We will use Nginx to serve your pages and Cloudflare to make your site faster and more secure.

Why do this? Using Cloudflare adds a protective shield to your site and helps it load faster for visitors. Nginx is a high-performance tool that handles web traffic efficiently.

What happens when done? You will have a professional, secure website running on your own server, fully connected to Cloudflare’s global network.

Setting up Cloudflare

First, you need a Cloudflare account. If you don’t have one, sign up at registered a domain name.

https://dash.cloudflare.com/sign-up

Enter your email and click Create Account.

Cloudflare WordPress setup

Once logged in, click the “Add a Site” button.

Cloudflare WordPress setup

Type in your domain name. registered

Cloudflare WordPress setup

Cloudflare will scan your domain for existing records.

Cloudflare WordPress setup

Select the free plan.

Cloudflare WordPress setup

Cloudflare will give you two nameservers. Log in to your domain registrar (where you bought your domain) and replace your current nameservers with these two.

This image has an empty alt attribute; its file name is cloudflare-setup-name-servers.png

Example: If your domain is at Google Domains, select “use custom nameservers” and save the new addresses.

Cloudflare WordPress Setup

It can take up to an hour for these changes to take effect. Check your Cloudflare dashboard until the status says “Active.”

This image has an empty alt attribute; its file name is cloudflare-overview-active.png

Your DNS entries should now appear in the Cloudflare dashboard.

Cloudflare WordPress Setup

Go to the SSL/TLS tab and set it to “Full (Strict).”

Cloudflare WordPress Setup

Scroll down to “Origin Certificates” and click “Create Certificate.”

This image has an empty alt attribute; its file name is cloudflare_wordpress_setup_8.png

Let Cloudflare generate the key and click Next.

WordPress Cloudflare

You will need to create three files on your server using these commands. (Requires admin privileges)

🐧Bash / Shell
sudo nano /etc/ssl/private/cloudflare_key_example.com.pem
🐧Bash / Shell
sudo nano /etc/ssl/certs/cloudflare_example.com.pem

Download the Cloudflare Origin Pull certificate here: Set up authenticated Origin pulls · Cloudflare SSL docs

🐧Bash / Shell
sudo nano /etc/ssl/certs/origin-pull-ca.pem

You now have three files: cloudflare_key_example.com.pem, cloudflare_example.com.pem, and origin-pull-ca.pem.

This image has an empty alt attribute; its file name is cloudflare_wordpress_setup_10.png

In the Cloudflare dashboard, turn on “Always Use HTTPS.”

This image has an empty alt attribute; its file name is cloudflare_wordpress_setup_11.png

Turn on “Authenticated Origin Pulls” and “Opportunistic Encryption.”

This image has an empty alt attribute; its file name is cloudflare_wordpress_setup_12.png

Turn on “Automatic HTTPS Rewrites.”

This image has an empty alt attribute; its file name is cloudflare_wordpress_setup_13.png

Go to “Page Rules” and create a rule to always use HTTPS for your domain.

This image has an empty alt attribute; its file name is cloudflare_wordpress_setup_15.png

Install and Configure Joomla

Log in to your server. (Requires admin privileges)

Install Nginx:

🐧Bash / Shell
sudo apt update
sudo apt install nginx

Use these commands to manage the service:

🐧Bash / Shell
sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Test your server by visiting your site address in a browser.

nginx default home page test

Install MariaDB Database

Joomla needs a database to store content. Install it with these commands:

🐧Bash / Shell
sudo apt-get install mariadb-server mariadb-client

Set the service to run on boot:

🐧Bash / Shell
sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service
🐧Bash / Shell
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Secure your database:

🐧Bash / Shell
sudo mysql_secure_installation

Follow the on-screen prompts to set a password and remove test settings.

🐧Bash / Shell
sudo mysql -u root -p
mariadb welcome

Install PHP

Joomla runs on PHP. Install it with these commands:

🐧Bash / Shell
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
🐧Bash / Shell
sudo apt update
🐧Bash / Shell
sudo apt install php7.2-fpm php7.2-common php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip

Edit the configuration file:

🐧Bash / Shell
sudo nano /etc/php/7.2/fpm/php.ini

Update settings and save:

💻Code
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

Restart Nginx:

🐧Bash / Shell
sudo systemctl restart nginx.service

Create a test file to verify PHP:

🐧Bash / Shell
sudo nano /var/www/html/phpinfo.php
💻Code

Visit your site address followed by /phpinfo.php to see the test page.

PHP Test Page

Create Joomla Database

Log in to the database:

🐧Bash / Shell
sudo mysql -u root -p

Create the database and user:

💻Code
CREATE DATABASE joomla;
💻Code
CREATE USER 'joomlauser'@'localhost' IDENTIFIED BY 'new_password_here';
💻Code
GRANT ALL ON joomla.* TO 'joomlauser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;
💻Code
FLUSH PRIVILEGES;
EXIT;

Install Joomla

Download and extract the latest version:

Command Prompt
cd /tmp
wget https://downloads.joomla.org/cms/joomla3/3-9-5/joomla_3-9-5-stable-full_package-zip
sudo unzip -d /var/www/html/example.com /tmp/joomla_3-9-5-stable-full_package-zip

Set permissions:

🐧Bash / Shell
sudo chown -R www-data:www-data /var/www/html/example.com/
sudo chmod -R 755 /var/www/html/example.com/

Configure Nginx for your site:

🐧Bash / Shell
sudo nano /etc/nginx/sites-available/example.com

Add your domain settings and certificate references:

🐘PHP
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;

server_name example.com www.example.com;
root /var/www/html/example.com;
index index.php;

ssl_certificate /etc/ssl/certs/cloudflare_example.com.pem;
ssl_certificate_key /etc/ssl/private/cloudflare_key_example.com.pem;
ssl_client_certificate /etc/ssl/certs/origin-pull-ca.pem;
ssl_verify_client on;

client_max_body_size 100M;

autoindex off;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

Enable the site:

🐧Bash / Shell
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo systemctl restart nginx.service

Visit your domain in a browser to finish the setup wizard.

Joomla installation on Ubuntu

Enter your database info:

Joomla installation on Ubuntu

Confirm settings and install:

Joomla installation on Ubuntu

Remove the installation folder:

Joomla installation on Ubuntu

Log in to your dashboard:

Joomla installation on Ubuntu
Joomla Ubuntu install
🐧Bash / Shell
sudo rm -rf /var/www/html/joomla/installation

Summary

You have successfully installed Joomla on an Ubuntu server protected by Nginx and Cloudflare. You configured a database, added SSL encryption for security, and set up a custom domain. Your site is now ready for content.

[Y/n]

[Y/n]

[Y/n]

[Y/n]

[Y/n]

What are the benefits of using Joomla with Nginx and Cloudflare?

Using Joomla with Nginx and Cloudflare enhances website performance and security. Nginx serves static content quickly, while Cloudflare provides CDN services and SSL support, improving load times and protecting against threats.


How do I sign up for a Cloudflare account?

To sign up for a Cloudflare account, visit the Cloudflare sign-up page, enter your email address, and click 'Create Account'. After verifying your email, you can start adding your domain to the Cloudflare service.


What steps do I need to follow to change my domain's nameservers to Cloudflare?

After adding your site to Cloudflare, you will receive nameservers. Log in to your domain provider's portal, navigate to your domain settings, and replace the existing nameservers with the ones provided by Cloudflare. Save the changes to apply.


How long does it take for DNS changes to propagate after updating nameservers?

DNS changes can take up to an hour to propagate, depending on your domain provider. You can check the status in your Cloudflare account to see when your site becomes active.


Can I use Cloudflare with other CMSs or plain HTML sites?

Yes, Cloudflare can be used with various content management systems and even plain HTML sites. Its CDN and security features are versatile and beneficial for any type of web project.

Was this guide helpful?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version